﻿
Partial Public Class Providers
    Inherits BaseUserControl

    Private Sub PrepareMembershipProvider()
        With drpMembershipProviders
            .Items.Clear()
            .DataSource = Membership.Providers
            .DataTextField = "ApplicationName"
            .DataValueField = "ApplicationName"
            .DataBind()
            .SelectedValue = Membership.ApplicationName
        End With
    End Sub

    Private Sub PrepareRoleProvider()
        drpRoleProviders.Items.Clear()
        For Each p As RoleProvider In Roles.Providers
            Dim x As New ListItem(p.ApplicationName, p.ApplicationName)
            drpRoleProviders.Items.Add(p.ApplicationName)
            If Roles.ApplicationName = p.ApplicationName Then
                drpRoleProviders.SelectedValue = p.ApplicationName
            End If
        Next

        'With drpRoleProviders
        '    .Items.Clear()
        '    .DataSource = Roles.Providers
        '    .DataTextField = "ApplicationName"
        '    .DataValueField = "ApplicationName"
        '    .DataBind()
        '    .SelectedValue = Roles.ApplicationName
        'End With
    End Sub

    Protected Sub drpRoleProviders_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles drpRoleProviders.SelectedIndexChanged
        Roles.ApplicationName = drpRoleProviders.SelectedItem.Text
        Me.NotifyUpdate(sender, e)
    End Sub

    Private Sub drpMembershipProviders_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles drpMembershipProviders.SelectedIndexChanged
        Membership.ApplicationName = drpMembershipProviders.SelectedValue
        Me.NotifyUpdate(sender, e)
    End Sub

    Public Overrides Sub Rebind()

    End Sub

    Private Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
        PrepareRoleProvider()
        PrepareMembershipProvider()
    End Sub
End Class